﻿namespace Chain.IDAL
{
    using Chain.DBUtility;
    using Chain.Model;
    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Runtime.InteropServices;
    using System.Text;

    public class MicroWebsiteOrderLog
    {
        public int Add(Chain.Model.MicroWebsiteOrderLog model)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("insert into MicroWebsiteOrderLog(");
            builder.Append("MicroOrderAccount,MicroOrderType,MicroOrderMemID,MicroOrderTotalMoney,MicroOrderDiscountMoney,MicroOrderIsCard,MicroOrderPayCard,MicroOrderIsCash,MicroOrderPayCash,MicroOrderIsBink,MicroOrderPayBink,MicroOrderPayCoupon,MicroOrderPoint,MicroOrderRemark,MicroOrderShopID,MicroOrderUserID,MicroOrderCreateTime,MicroOldAccount,MicroOrderCardBalance,MicroOrderCardPoint,MicroOrderName,MicroOrderMobile,MicroOrderAdress,MicroOrderStatus,MicroOrderPassCreateTime,MicroOrderMark,MicroOrderPayCreateTime)");
            builder.Append(" values (");
            builder.Append("@MicroOrderAccount,@MicroOrderType,@MicroOrderMemID,@MicroOrderTotalMoney,@MicroOrderDiscountMoney,@MicroOrderIsCard,@MicroOrderPayCard,@MicroOrderIsCash,@MicroOrderPayCash,@MicroOrderIsBink,@MicroOrderPayBink,@MicroOrderPayCoupon,@MicroOrderPoint,@MicroOrderRemark,@MicroOrderShopID,@MicroOrderUserID,@MicroOrderCreateTime,@MicroOldAccount,@MicroOrderCardBalance,@MicroOrderCardPoint,@MicroOrderName,@MicroOrderMobile,@MicroOrderAdress,@MicroOrderStatus,@MicroOrderPassCreateTime,@MicroOrderMark,@MicroOrderPayCreateTime)");
            builder.Append(";select @@IDENTITY");
            SqlParameter[] cmdParms = new SqlParameter[] { 
                new SqlParameter("@MicroOrderAccount", SqlDbType.NVarChar, 50), new SqlParameter("@MicroOrderType", SqlDbType.TinyInt, 1), new SqlParameter("@MicroOrderMemID", SqlDbType.Int, 4), new SqlParameter("@MicroOrderTotalMoney", SqlDbType.Money, 8), new SqlParameter("@MicroOrderDiscountMoney", SqlDbType.Money, 8), new SqlParameter("@MicroOrderIsCard", SqlDbType.Bit, 1), new SqlParameter("@MicroOrderPayCard", SqlDbType.Money, 8), new SqlParameter("@MicroOrderIsCash", SqlDbType.Bit, 1), new SqlParameter("@MicroOrderPayCash", SqlDbType.Money, 8), new SqlParameter("@MicroOrderIsBink", SqlDbType.Bit, 1), new SqlParameter("@MicroOrderPayBink", SqlDbType.Money, 8), new SqlParameter("@MicroOrderPayCoupon", SqlDbType.Money, 8), new SqlParameter("@MicroOrderPoint", SqlDbType.Int, 4), new SqlParameter("@MicroOrderRemark", SqlDbType.NVarChar, 200), new SqlParameter("@MicroOrderShopID", SqlDbType.Int, 4), new SqlParameter("@MicroOrderUserID", SqlDbType.Int, 4), 
                new SqlParameter("@MicroOrderCreateTime", SqlDbType.DateTime), new SqlParameter("@MicroOldAccount", SqlDbType.NVarChar, 50), new SqlParameter("@MicroOrderCardBalance", SqlDbType.Money, 8), new SqlParameter("@MicroOrderCardPoint", SqlDbType.Int, 4), new SqlParameter("@MicroOrderName", SqlDbType.NVarChar, 50), new SqlParameter("@MicroOrderMobile", SqlDbType.NVarChar, 50), new SqlParameter("@MicroOrderAdress", SqlDbType.NVarChar, 500), new SqlParameter("@MicroOrderStatus", SqlDbType.Int, 4), new SqlParameter("@MicroOrderPassCreateTime", SqlDbType.DateTime), new SqlParameter("@MicroOrderMark", SqlDbType.NVarChar, 0x3e8), new SqlParameter("@MicroOrderPayCreateTime", SqlDbType.DateTime)
             };
            cmdParms[0].Value = model.MicroOrderAccount;
            cmdParms[1].Value = model.MicroOrderType;
            cmdParms[2].Value = model.MicroOrderMemID;
            cmdParms[3].Value = model.MicroOrderTotalMoney;
            cmdParms[4].Value = model.MicroOrderDiscountMoney;
            cmdParms[5].Value = model.MicroOrderIsCard;
            cmdParms[6].Value = model.MicroOrderPayCard;
            cmdParms[7].Value = model.MicroOrderIsCash;
            cmdParms[8].Value = model.MicroOrderPayCash;
            cmdParms[9].Value = model.MicroOrderIsBink;
            cmdParms[10].Value = model.MicroOrderPayBink;
            cmdParms[11].Value = model.MicroOrderPayCoupon;
            cmdParms[12].Value = model.MicroOrderPoint;
            cmdParms[13].Value = model.MicroOrderRemark;
            cmdParms[14].Value = model.MicroOrderShopID;
            cmdParms[15].Value = model.MicroOrderUserID;
            cmdParms[0x10].Value = model.MicroOrderCreateTime;
            cmdParms[0x11].Value = model.MicroOldAccount;
            cmdParms[0x12].Value = model.MicroOrderCardBalance;
            cmdParms[0x13].Value = model.MicroOrderCardPoint;
            cmdParms[20].Value = model.MicroOrderName;
            cmdParms[0x15].Value = model.MicroOrderMobile;
            cmdParms[0x16].Value = model.MicroOrderAdress;
            cmdParms[0x17].Value = model.MicroOrderStatus;
            cmdParms[0x18].Value = model.MicroOrderPassCreateTime;
            cmdParms[0x19].Value = model.MicroOrderMark;
            cmdParms[0x1a].Value = model.MicroOrderPayCreateTime;
            object single = DbHelperSQL.GetSingle(builder.ToString(), cmdParms);
            if (single == null)
            {
                return 0;
            }
            return Convert.ToInt32(single);
        }

        public bool Delete(int MicroOrderID)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("delete from MicroWebsiteOrderLog ");
            builder.Append(" where MicroOrderID=@MicroOrderID");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@MicroOrderID", SqlDbType.Int, 4) };
            cmdParms[0].Value = MicroOrderID;
            return (DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }

        public bool DeleteList(string MicroOrderIDlist)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("delete from MicroWebsiteOrderLog ");
            builder.Append(" where MicroOrderID in (" + MicroOrderIDlist + ")  ");
            return (DbHelperSQL.ExecuteSql(builder.ToString()) > 0);
        }

        public bool Exists(int MicroOrderID)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select count(1) from MicroWebsiteOrderLog");
            builder.Append(" where MicroOrderID=@MicroOrderID");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@MicroOrderID", SqlDbType.Int, 4) };
            cmdParms[0].Value = MicroOrderID;
            return DbHelperSQL.Exists(builder.ToString(), cmdParms);
        }

        public DataSet GetList(string strWhere)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select MicroOrderID,MicroOrderAccount,MicroOrderType,MicroOrderMemID,MicroOrderTotalMoney,MicroOrderDiscountMoney,MicroOrderIsCard,MicroOrderPayCard,MicroOrderIsCash,MicroOrderPayCash,MicroOrderIsBink,MicroOrderPayBink,MicroOrderPayCoupon,MicroOrderPoint,MicroOrderRemark,MicroOrderShopID,MicroOrderUserID,MicroOrderCreateTime,MicroOldAccount,MicroOrderCardBalance,MicroOrderCardPoint,MicroOrderName,MicroOrderMobile,MicroOrderAdress,MicroOrderStatus,MicroOrderPassCreateTime,MicroOrderMark,MicroOrderPayCreateTime ");
            builder.Append(" FROM MicroWebsiteOrderLog ");
            if (strWhere.Trim() != "")
            {
                builder.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(builder.ToString());
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select ");
            if (Top > 0)
            {
                builder.Append(" top " + Top.ToString());
            }
            builder.Append(" MicroOrderID,MicroOrderAccount,MicroOrderType,MicroOrderMemID,MicroOrderTotalMoney,MicroOrderDiscountMoney,MicroOrderIsCard,MicroOrderPayCard,MicroOrderIsCash,MicroOrderPayCash,MicroOrderIsBink,MicroOrderPayBink,MicroOrderPayCoupon,MicroOrderPoint,MicroOrderRemark,MicroOrderShopID,MicroOrderUserID,MicroOrderCreateTime,MicroOldAccount,MicroOrderCardBalance,MicroOrderCardPoint,MicroOrderName,MicroOrderMobile,MicroOrderAdress,MicroOrderStatus,MicroOrderPassCreateTime,MicroOrderMark,MicroOrderPayCreateTime ");
            builder.Append(" FROM MicroWebsiteOrderLog ");
            if (strWhere.Trim() != "")
            {
                builder.Append(" where " + strWhere);
            }
            builder.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(builder.ToString());
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("SELECT * FROM ( ");
            builder.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                builder.Append("order by T." + orderby);
            }
            else
            {
                builder.Append("order by T.MicroOrderID desc");
            }
            builder.Append(")AS Row, T.*  from MicroWebsiteOrderLog T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                builder.Append(" WHERE " + strWhere);
            }
            builder.Append(" ) TT");
            builder.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(builder.ToString());
        }

        public DataSet GetListSP(int PageSize, int PageIndex, out int resCount, params string[] strWhere)
        {
            string tableName = "MicroWebsiteOrderLog,Mem,SysShop,SysUser";
            string[] column = new string[] { "MicroWebsiteOrderLog.*,Mem.MemName,Mem.MemCard,Mem.MemMoney,Mem.MemID,Mem.MemLevelID,SysShop.ShopName,SysUser.UserName,(select count(MicroOrderLogDetailID) from MicroWebsiteOrderLogDetail where MicroWebsiteOrderLogDetail.MicroOrderID= MicroWebsiteOrderLog.MicroOrderID ) as Count" };
            string[] condition = strWhere;
            int recordCount = 1;
            DataSet set = DbHelperSQL.GetTable(tableName, column, condition, "MicroOrderCreateTime", "MicroOrderID", false, PageSize, PageIndex, recordCount);
            resCount = int.Parse(set.Tables[1].Rows[0][0].ToString());
            return set;
        }

        public DataSet GetListSP1(int PageSize, int PageIndex, out int resCount, params string[] strWhere)
        {
            string tableName = "MicroWebsiteOrderLog,Mem,SysShop";
            string[] column = new string[] { "MicroWebsiteOrderLog.*,Mem.MemName,Mem.MemCard,Mem.MemID,Mem.MemLevelID,SysShop.ShopName,(select count(MicroOrderLogDetailID) from MicroWebsiteOrderLogDetail where MicroWebsiteOrderLogDetail.MicroOrderID= MicroWebsiteOrderLog.MicroOrderID ) as Count" };
            string[] condition = strWhere;
            int recordCount = 1;
            DataSet set = DbHelperSQL.GetTable(tableName, column, condition, "MicroOrderCreateTime", "MicroOrderID", false, PageSize, PageIndex, recordCount);
            resCount = int.Parse(set.Tables[1].Rows[0][0].ToString());
            return set;
        }

        public Chain.Model.MicroWebsiteOrderLog GetModel(int MicroOrderID)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select  top 1 MicroOrderID,MicroOrderAccount,MicroOrderType,MicroOrderMemID,MicroOrderTotalMoney,MicroOrderDiscountMoney,MicroOrderIsCard,MicroOrderPayCard,MicroOrderIsCash,MicroOrderPayCash,MicroOrderIsBink,MicroOrderPayBink,MicroOrderPayCoupon,MicroOrderPoint,MicroOrderRemark,MicroOrderShopID,MicroOrderUserID,MicroOrderCreateTime,MicroOldAccount,MicroOrderCardBalance,MicroOrderCardPoint,MicroOrderName,MicroOrderMobile,MicroOrderAdress,MicroOrderStatus,MicroOrderPassCreateTime,MicroOrderMark,MicroOrderPayCreateTime from MicroWebsiteOrderLog ");
            builder.Append(" where MicroOrderID=@MicroOrderID");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@MicroOrderID", SqlDbType.Int, 4) };
            cmdParms[0].Value = MicroOrderID;
            Chain.Model.MicroWebsiteOrderLog log = new Chain.Model.MicroWebsiteOrderLog();
            DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
            if (set.Tables[0].Rows.Count <= 0)
            {
                return null;
            }
            if ((set.Tables[0].Rows[0]["MicroOrderID"] != null) && (set.Tables[0].Rows[0]["MicroOrderID"].ToString() != ""))
            {
                log.MicroOrderID = int.Parse(set.Tables[0].Rows[0]["MicroOrderID"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderAccount"] != null) && (set.Tables[0].Rows[0]["MicroOrderAccount"].ToString() != ""))
            {
                log.MicroOrderAccount = set.Tables[0].Rows[0]["MicroOrderAccount"].ToString();
            }
            if ((set.Tables[0].Rows[0]["MicroOrderType"] != null) && (set.Tables[0].Rows[0]["MicroOrderType"].ToString() != ""))
            {
                log.MicroOrderType = int.Parse(set.Tables[0].Rows[0]["MicroOrderType"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderMemID"] != null) && (set.Tables[0].Rows[0]["MicroOrderMemID"].ToString() != ""))
            {
                log.MicroOrderMemID = int.Parse(set.Tables[0].Rows[0]["MicroOrderMemID"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderTotalMoney"] != null) && (set.Tables[0].Rows[0]["MicroOrderTotalMoney"].ToString() != ""))
            {
                log.MicroOrderTotalMoney = decimal.Parse(set.Tables[0].Rows[0]["MicroOrderTotalMoney"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderDiscountMoney"] != null) && (set.Tables[0].Rows[0]["MicroOrderDiscountMoney"].ToString() != ""))
            {
                log.MicroOrderDiscountMoney = decimal.Parse(set.Tables[0].Rows[0]["MicroOrderDiscountMoney"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderIsCard"] != null) && (set.Tables[0].Rows[0]["MicroOrderIsCard"].ToString() != ""))
            {
                if ((set.Tables[0].Rows[0]["MicroOrderIsCard"].ToString() == "1") || (set.Tables[0].Rows[0]["MicroOrderIsCard"].ToString().ToLower() == "true"))
                {
                    log.MicroOrderIsCard = true;
                }
                else
                {
                    log.MicroOrderIsCard = false;
                }
            }
            if ((set.Tables[0].Rows[0]["MicroOrderPayCard"] != null) && (set.Tables[0].Rows[0]["MicroOrderPayCard"].ToString() != ""))
            {
                log.MicroOrderPayCard = decimal.Parse(set.Tables[0].Rows[0]["MicroOrderPayCard"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderIsCash"] != null) && (set.Tables[0].Rows[0]["MicroOrderIsCash"].ToString() != ""))
            {
                if ((set.Tables[0].Rows[0]["MicroOrderIsCash"].ToString() == "1") || (set.Tables[0].Rows[0]["MicroOrderIsCash"].ToString().ToLower() == "true"))
                {
                    log.MicroOrderIsCash = true;
                }
                else
                {
                    log.MicroOrderIsCash = false;
                }
            }
            if ((set.Tables[0].Rows[0]["MicroOrderPayCash"] != null) && (set.Tables[0].Rows[0]["MicroOrderPayCash"].ToString() != ""))
            {
                log.MicroOrderPayCash = decimal.Parse(set.Tables[0].Rows[0]["MicroOrderPayCash"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderIsBink"] != null) && (set.Tables[0].Rows[0]["MicroOrderIsBink"].ToString() != ""))
            {
                if ((set.Tables[0].Rows[0]["MicroOrderIsBink"].ToString() == "1") || (set.Tables[0].Rows[0]["MicroOrderIsBink"].ToString().ToLower() == "true"))
                {
                    log.MicroOrderIsBink = true;
                }
                else
                {
                    log.MicroOrderIsBink = false;
                }
            }
            if ((set.Tables[0].Rows[0]["MicroOrderPayBink"] != null) && (set.Tables[0].Rows[0]["MicroOrderPayBink"].ToString() != ""))
            {
                log.MicroOrderPayBink = decimal.Parse(set.Tables[0].Rows[0]["MicroOrderPayBink"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderPayCoupon"] != null) && (set.Tables[0].Rows[0]["MicroOrderPayCoupon"].ToString() != ""))
            {
                log.MicroOrderPayCoupon = decimal.Parse(set.Tables[0].Rows[0]["MicroOrderPayCoupon"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderPoint"] != null) && (set.Tables[0].Rows[0]["MicroOrderPoint"].ToString() != ""))
            {
                log.MicroOrderPoint = int.Parse(set.Tables[0].Rows[0]["MicroOrderPoint"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderRemark"] != null) && (set.Tables[0].Rows[0]["MicroOrderRemark"].ToString() != ""))
            {
                log.MicroOrderRemark = set.Tables[0].Rows[0]["MicroOrderRemark"].ToString();
            }
            if ((set.Tables[0].Rows[0]["MicroOrderShopID"] != null) && (set.Tables[0].Rows[0]["MicroOrderShopID"].ToString() != ""))
            {
                log.MicroOrderShopID = int.Parse(set.Tables[0].Rows[0]["MicroOrderShopID"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderUserID"] != null) && (set.Tables[0].Rows[0]["MicroOrderUserID"].ToString() != ""))
            {
                log.MicroOrderUserID = int.Parse(set.Tables[0].Rows[0]["MicroOrderUserID"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderCreateTime"] != null) && (set.Tables[0].Rows[0]["MicroOrderCreateTime"].ToString() != ""))
            {
                log.MicroOrderCreateTime = DateTime.Parse(set.Tables[0].Rows[0]["MicroOrderCreateTime"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOldAccount"] != null) && (set.Tables[0].Rows[0]["MicroOldAccount"].ToString() != ""))
            {
                log.MicroOldAccount = set.Tables[0].Rows[0]["MicroOldAccount"].ToString();
            }
            if ((set.Tables[0].Rows[0]["MicroOrderCardBalance"] != null) && (set.Tables[0].Rows[0]["MicroOrderCardBalance"].ToString() != ""))
            {
                log.MicroOrderCardBalance = decimal.Parse(set.Tables[0].Rows[0]["MicroOrderCardBalance"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderCardPoint"] != null) && (set.Tables[0].Rows[0]["MicroOrderCardPoint"].ToString() != ""))
            {
                log.MicroOrderCardPoint = int.Parse(set.Tables[0].Rows[0]["MicroOrderCardPoint"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderName"] != null) && (set.Tables[0].Rows[0]["MicroOrderName"].ToString() != ""))
            {
                log.MicroOrderName = set.Tables[0].Rows[0]["MicroOrderName"].ToString();
            }
            if ((set.Tables[0].Rows[0]["MicroOrderMobile"] != null) && (set.Tables[0].Rows[0]["MicroOrderMobile"].ToString() != ""))
            {
                log.MicroOrderMobile = set.Tables[0].Rows[0]["MicroOrderMobile"].ToString();
            }
            if ((set.Tables[0].Rows[0]["MicroOrderAdress"] != null) && (set.Tables[0].Rows[0]["MicroOrderAdress"].ToString() != ""))
            {
                log.MicroOrderAdress = set.Tables[0].Rows[0]["MicroOrderAdress"].ToString();
            }
            if ((set.Tables[0].Rows[0]["MicroOrderStatus"] != null) && (set.Tables[0].Rows[0]["MicroOrderStatus"].ToString() != ""))
            {
                log.MicroOrderStatus = int.Parse(set.Tables[0].Rows[0]["MicroOrderStatus"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderPassCreateTime"] != null) && (set.Tables[0].Rows[0]["MicroOrderPassCreateTime"].ToString() != ""))
            {
                log.MicroOrderPassCreateTime = DateTime.Parse(set.Tables[0].Rows[0]["MicroOrderPassCreateTime"].ToString());
            }
            if ((set.Tables[0].Rows[0]["MicroOrderMark"] != null) && (set.Tables[0].Rows[0]["MicroOrderMark"].ToString() != ""))
            {
                log.MicroOrderMark = set.Tables[0].Rows[0]["MicroOrderMark"].ToString();
            }
            if ((set.Tables[0].Rows[0]["MicroOrderPayCreateTime"] != null) && (set.Tables[0].Rows[0]["MicroOrderPayCreateTime"].ToString() != ""))
            {
                log.MicroOrderPayCreateTime = DateTime.Parse(set.Tables[0].Rows[0]["MicroOrderPayCreateTime"].ToString());
            }
            return log;
        }

        public int GetRecordCount(string strWhere)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select count(1) FROM MicroWebsiteOrderLog ");
            if (strWhere.Trim() != "")
            {
                builder.Append(" where " + strWhere);
            }
            object single = DbHelperSQL.GetSingle(builder.ToString());
            if (single == null)
            {
                return 0;
            }
            return Convert.ToInt32(single);
        }

        public bool Update(Chain.Model.MicroWebsiteOrderLog model)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("update MicroWebsiteOrderLog set ");
            builder.Append("MicroOrderAccount=@MicroOrderAccount,");
            builder.Append("MicroOrderType=@MicroOrderType,");
            builder.Append("MicroOrderMemID=@MicroOrderMemID,");
            builder.Append("MicroOrderTotalMoney=@MicroOrderTotalMoney,");
            builder.Append("MicroOrderDiscountMoney=@MicroOrderDiscountMoney,");
            builder.Append("MicroOrderIsCard=@MicroOrderIsCard,");
            builder.Append("MicroOrderPayCard=@MicroOrderPayCard,");
            builder.Append("MicroOrderIsCash=@MicroOrderIsCash,");
            builder.Append("MicroOrderPayCash=@MicroOrderPayCash,");
            builder.Append("MicroOrderIsBink=@MicroOrderIsBink,");
            builder.Append("MicroOrderPayBink=@MicroOrderPayBink,");
            builder.Append("MicroOrderPayCoupon=@MicroOrderPayCoupon,");
            builder.Append("MicroOrderPoint=@MicroOrderPoint,");
            builder.Append("MicroOrderRemark=@MicroOrderRemark,");
            builder.Append("MicroOrderShopID=@MicroOrderShopID,");
            builder.Append("MicroOrderUserID=@MicroOrderUserID,");
            builder.Append("MicroOrderCreateTime=@MicroOrderCreateTime,");
            builder.Append("MicroOldAccount=@MicroOldAccount,");
            builder.Append("MicroOrderCardBalance=@MicroOrderCardBalance,");
            builder.Append("MicroOrderCardPoint=@MicroOrderCardPoint,");
            builder.Append("MicroOrderName=@MicroOrderName,");
            builder.Append("MicroOrderMobile=@MicroOrderMobile,");
            builder.Append("MicroOrderAdress=@MicroOrderAdress,");
            builder.Append("MicroOrderStatus=@MicroOrderStatus,");
            builder.Append("MicroOrderPassCreateTime=@MicroOrderPassCreateTime,");
            builder.Append("MicroOrderMark=@MicroOrderMark,");
            builder.Append("MicroOrderPayCreateTime=@MicroOrderPayCreateTime");
            builder.Append(" where MicroOrderID=@MicroOrderID");
            SqlParameter[] cmdParms = new SqlParameter[] { 
                new SqlParameter("@MicroOrderAccount", SqlDbType.NVarChar, 50), new SqlParameter("@MicroOrderType", SqlDbType.TinyInt, 1), new SqlParameter("@MicroOrderMemID", SqlDbType.Int, 4), new SqlParameter("@MicroOrderTotalMoney", SqlDbType.Money, 8), new SqlParameter("@MicroOrderDiscountMoney", SqlDbType.Money, 8), new SqlParameter("@MicroOrderIsCard", SqlDbType.Bit, 1), new SqlParameter("@MicroOrderPayCard", SqlDbType.Money, 8), new SqlParameter("@MicroOrderIsCash", SqlDbType.Bit, 1), new SqlParameter("@MicroOrderPayCash", SqlDbType.Money, 8), new SqlParameter("@MicroOrderIsBink", SqlDbType.Bit, 1), new SqlParameter("@MicroOrderPayBink", SqlDbType.Money, 8), new SqlParameter("@MicroOrderPayCoupon", SqlDbType.Money, 8), new SqlParameter("@MicroOrderPoint", SqlDbType.Int, 4), new SqlParameter("@MicroOrderRemark", SqlDbType.NVarChar, 200), new SqlParameter("@MicroOrderShopID", SqlDbType.Int, 4), new SqlParameter("@MicroOrderUserID", SqlDbType.Int, 4), 
                new SqlParameter("@MicroOrderCreateTime", SqlDbType.DateTime), new SqlParameter("@MicroOldAccount", SqlDbType.NVarChar, 50), new SqlParameter("@MicroOrderCardBalance", SqlDbType.Money, 8), new SqlParameter("@MicroOrderCardPoint", SqlDbType.Int, 4), new SqlParameter("@MicroOrderName", SqlDbType.NVarChar, 50), new SqlParameter("@MicroOrderMobile", SqlDbType.NVarChar, 50), new SqlParameter("@MicroOrderAdress", SqlDbType.NVarChar, 500), new SqlParameter("@MicroOrderStatus", SqlDbType.Int, 4), new SqlParameter("@MicroOrderPassCreateTime", SqlDbType.DateTime), new SqlParameter("@MicroOrderMark", SqlDbType.NVarChar, 0x3e8), new SqlParameter("@MicroOrderPayCreateTime", SqlDbType.DateTime), new SqlParameter("@MicroOrderID", SqlDbType.Int, 4)
             };
            cmdParms[0].Value = model.MicroOrderAccount;
            cmdParms[1].Value = model.MicroOrderType;
            cmdParms[2].Value = model.MicroOrderMemID;
            cmdParms[3].Value = model.MicroOrderTotalMoney;
            cmdParms[4].Value = model.MicroOrderDiscountMoney;
            cmdParms[5].Value = model.MicroOrderIsCard;
            cmdParms[6].Value = model.MicroOrderPayCard;
            cmdParms[7].Value = model.MicroOrderIsCash;
            cmdParms[8].Value = model.MicroOrderPayCash;
            cmdParms[9].Value = model.MicroOrderIsBink;
            cmdParms[10].Value = model.MicroOrderPayBink;
            cmdParms[11].Value = model.MicroOrderPayCoupon;
            cmdParms[12].Value = model.MicroOrderPoint;
            cmdParms[13].Value = model.MicroOrderRemark;
            cmdParms[14].Value = model.MicroOrderShopID;
            cmdParms[15].Value = model.MicroOrderUserID;
            cmdParms[0x10].Value = model.MicroOrderCreateTime;
            cmdParms[0x11].Value = model.MicroOldAccount;
            cmdParms[0x12].Value = model.MicroOrderCardBalance;
            cmdParms[0x13].Value = model.MicroOrderCardPoint;
            cmdParms[20].Value = model.MicroOrderName;
            cmdParms[0x15].Value = model.MicroOrderMobile;
            cmdParms[0x16].Value = model.MicroOrderAdress;
            cmdParms[0x17].Value = model.MicroOrderStatus;
            cmdParms[0x18].Value = model.MicroOrderPassCreateTime;
            cmdParms[0x19].Value = model.MicroOrderMark;
            cmdParms[0x1a].Value = model.MicroOrderPayCreateTime;
            cmdParms[0x1b].Value = model.MicroOrderID;
            return (DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
    }
}

